<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script>
			/**
			 * 第二题
			 * @returns {string}
			 */
			function stringconcat() {
				var result = [];
				stringconcat.merge.call(null, result, arguments);
				return result.join("+");
			}
			stringconcat.prefix = function() {
				var _arguments = [],
					_this = this;
				_this.merge.call(null, _arguments, arguments);
				return function() {
					var _args = _arguments.slice(0);
					_this.merge.call(null, _args, arguments);
					return _this.apply(null, _args);
				};
			};
			stringconcat.merge = function(array, arrayLike) {
					var i = 0;
					for (i = 0; i < arrayLike.length; i++) {
						array.push(arrayLike[i]);
					}
				}
				//测试用例
			var result1 = stringconcat("a", "b"); //result1 = "a+b"
			var result3 = stringconcat("c", "d"); //result1 = "a+b"
			var stringconcatWithPrefix = stringconcat.prefix("hellworld");
			var stringconcatWithPrefix1 = stringconcat.prefix("hellworld1");
			var result2 = stringconcatWithPrefix("a", "b"); //result2 = "hellworld+a+b"
			var result4 = stringconcatWithPrefix1("c", "d"); //result2 = "hellworld+a+b"
			alert(result1);
			alert(result2);
			alert(result3);
			alert(result4);
		</script>
	</body>

</html>